﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

[Serializable]
public class InitShop
{
    public int id;
    /// <summary>
    /// 道具id
    /// </summary>
    public int item_id;
    /// <summary>
    /// 道具类型 1.消耗品 2.装备 3.英雄
    /// </summary>
    public int item_type;
    /// <summary>
    /// 货币类型 1.灵币商店 2.仙缘商店
    /// </summary>
    public int gold_type;
    /// <summary>
    /// 价格
    /// </summary>
    public int price;
    /// <summary>
    /// 最大数量
    /// </summary>
    public int max_count;
}

public class InitShopMgr
{
    public static Dictionary<long, InitShop> Dict { get; private set; }

    public static void Load()
    {
        List<InitShop> initRoles = StaticDataReader.LoadJsonFromFile<InitShop>("static_init_shop");
        if (initRoles != null)
        {
            Dict = new Dictionary<long, InitShop>(initRoles.Count);
            for(int i=0; i<initRoles.Count; i++)
            {
                Dict.Add(initRoles[i].id, initRoles[i]);
            }
        }
        else
        {
            Dict = new Dictionary<long, InitShop>();
        }
    }

    public static List<InitShop> GetByType(int shopType)
    {
        List<InitShop> initShops = new List<InitShop>();
        foreach (InitShop shop in Dict.Values)
        {
            if (shop.gold_type == shopType)
            {
                initShops.Add(shop);
            }
        }
        return initShops;
    }
}
